Skip to content

ASoC: SOF: loader: print DSP boot time in debug prints#5418

Closed
kv2019i wants to merge 2 commits intothesofproject:topic/sof-devfrom
kv2019i:202505-log-dsp-boot
Closed

ASoC: SOF: loader: print DSP boot time in debug prints#5418
kv2019i wants to merge 2 commits intothesofproject:topic/sof-devfrom
kv2019i:202505-log-dsp-boot

Conversation

@kv2019i
Copy link
Copy Markdown
Collaborator

@kv2019i kv2019i commented May 16, 2025

No description provided.

@kv2019i kv2019i requested review from lyakh and ranj063 as code owners May 16, 2025 16:44
@kv2019i kv2019i requested review from Copilot, ranj063 and ujfalusi and removed request for lyakh and ranj063 May 16, 2025 16:44
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

The PR adds debug prints to measure and log DSP firmware boot time in the SOF loader.

  • Introduces a timestamp capture at boot start using ktime_get().
  • Logs firmware boot completion with elapsed time, and similarly logs post-boot completion time after calling post_fw_boot().

@kv2019i kv2019i force-pushed the 202505-log-dsp-boot branch from e54d15f to 64cfde0 Compare May 16, 2025 16:46

return 0;
dev_dbg(sdev->dev, "firmware boot (post) complete, took %lldus\n",
ktime_us_delta(ktime_get(), boot_start));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is pointless to print out if the ops->post_fw_boot is not set, I would move it inside of the if() and print it only if ret == 0 with "Full firmware startup took %lldus\n".
Or you might want to break it down to firmware boot proper and post boot time.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started making these changes, but then changed my mind. post_fw_boot has the additional steps on Intel (IPC4) platforms, but there are also extra steps in snd_sof_dsp_post_fw_run(), and given these prints are added to common code, shouldn't we cover all the post boot steps in the measured time (DSP post_boot and IPC-version dependent post_boot)...?

Or is this too Intel specific and we should hide these prints to some more HW specific code? @dbaluta , what do you think?

It would still seem useful information to have (all platforms need to boot the FW).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think that this is pointless to print if sdev->ipc->ops->post_fw_boot == NULL

Also, a theoretical log:

firmware boot complete, took 100us
firmware boot (post) complete, took 140us

the full boot time is 100us+140us or 140us? I know the answer, but from the print I assume the former, while the later is the meaning.

and w/o post_fw_boot:

firmware boot complete, took 100us
firmware boot (post) complete, took 101us

The printk took 1us, is that really something which helps?

.state = SOF_DSP_PM_D0,
};
.state = SOF_DSP_PM_D0,
};
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be the first patch.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, sorry, I put this last on purpose. Now fixed in updated series.

Fix to use tabs for indentation.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
@kv2019i kv2019i force-pushed the 202505-log-dsp-boot branch from 64cfde0 to bce83c5 Compare May 22, 2025 14:05
@kv2019i kv2019i requested review from bardliao, dbaluta and ujfalusi June 4, 2025 11:10
bardliao
bardliao previously approved these changes Jun 5, 2025
@kv2019i
Copy link
Copy Markdown
Collaborator Author

kv2019i commented Jun 17, 2025

@ujfalusi @lyakh Is this useful addition or shall we close this?

@ujfalusi
Copy link
Copy Markdown
Collaborator

@ujfalusi @lyakh Is this useful addition or shall we close this?

I think this is useful, but needs some clarification.

DSP boot time is a key contributing factor to audio device set up time
with SOF. Add measurement of boot time and include it in the debug
messages.

Move the "firmware boot complete" message to end of the run_firmware()
function and include possible post_fw_boot() actions in the boot up
time.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
@kv2019i
Copy link
Copy Markdown
Collaborator Author

kv2019i commented Jun 17, 2025

New revision:

  • simplified the patch as per feedback from @ujfalusi

return 0;
if (!ret)
dev_dbg(sdev->dev, "firmware boot complete, took %lldus\n",
ktime_us_delta(ktime_get(), boot_start));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you fine with logging now the combined snd_sof_dsp_run() + snd_sof_dsp_post_fw_run() + sdev->ipc->ops->post_fw_boot() ?

Note: the basefw boot time can be deduced based on the timestamps in kernel log:

"booting DSP firmware"
...
"fw_state change: 6 -> 7"

if (sdev->fw_state == SOF_FW_BOOT_READY_FAILED)
return -EIO; /* FW boots but fw_ready op failed */

dev_dbg(sdev->dev, "firmware boot complete\n");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The firmware boot proper is done at this point to be pragmatic, from this point we have the post boot calls, which needs a running firmware on the DSP side...

@kv2019i
Copy link
Copy Markdown
Collaborator Author

kv2019i commented Jun 17, 2025

It's true there are many things we can measure here. Is boot time from trigger to FW_READY? Or should it include any steps to make the FW usable (e.g. post_fw_boot actions on Intel platforms)? And depending on what you are looking at, one might want to look at each step separately. I think more I think about it, a single number doesn't make sense and existing logs can be used to calculate the time already. Let me close this now.

@kv2019i kv2019i closed this Jun 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants